<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>自定义指令</title>
  <!-- 开发环境版本，包含了有帮助的命令行警告 -->
  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<div id="demo">

  <p v-upper-text="msg1"></p>
  <p v-lower-text="msg1"></p>

</div>
<script type="text/javascript">
  // 定义全局指令
  Vue.directive('upper-text',function (el,binding){
    console.log(el,binding);
    var value = binding.value;
    var s = value.toUpperCase();
    el.textContent = s;
  });
  Vue.directive('lower-text',function (el,binding){
    console.log(el,binding);
    var value = binding.value;
    var s = value.toLowerCase();
    el.textContent = s;
  });
  const vm = new Vue({
    el: '#demo',
    data:{
      msg1:'jfsdJJJfsdkkJJKKKK',
      msg2:'jfsdJJJfsdkkJJKKKK'
    }

  });
</script>
</body>

</html>